package org.sidora.strata.explorer;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.windows.TopComponent;
import org.sidora.core.Site;
import org.sidora.strata.Storage;

/**
 * Action which shows ZoneExplorer component.
 * @author Enric Tartera, Juan Manuel Gimeno, Roger Masgoret
 * @version 1.0
 */
public class ZoneExplorerAction extends AbstractAction {
    
    
    public ZoneExplorerAction() {
        super(NbBundle.getMessage(ZoneExplorerAction.class, "CTL_ZoneExplorerAction"));
//        putValue(SMALL_ICON, new ImageIcon(Utilities.loadImage(ZoneExplorerTopComponent.ICON_PATH, true)));
    }
    
    public void actionPerformed(ActionEvent evt) {
        TopComponent win = ZoneExplorerTopComponent.findInstance();
        win.setDisplayName("Zone");
        win.open();
        win.requestActive();
    }
    
    public void fillZoneItems(){
        ZoneExplorerTopComponent win = ZoneExplorerTopComponent.findInstance();
        win.fillZoneItems();
        Storage.setZone(null);
        Storage.setSector(null);
        Storage.setFeature(null);
        Storage.setContext(null);
        Storage.getSectorExplorerAction().fillSectorItems();
        Storage.getFeatureExplorerAction().fillFeatureItems();
        Storage.getContextExplorerAction().fillContextItems();
    }
    
    public void cerrar(){
        ZoneExplorerTopComponent win = ZoneExplorerTopComponent.findInstance();
        win.close();
    }
}
